<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>FMS</title>
    <!-- 引入Bootstrap -->
    <link rel="stylesheet" href="/static/Bootstrap/css/bootstrap.min.css"/>
    <!-- 引入jQuery -->
    <script src="/static/js/jquery-1.11.3.min.js"></script>
    <!-- 引入Bootstrap的JavaScript插件 -->
    <script src="/static/Bootstrap/js/bootstrap.min.js"></script>

    <link href="/static/css/sb-admin-2.css" rel="stylesheet"/>
    <script src="/static/js/sb-admin-2.js"></script>
    <link href="/static/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/common.css" rel="stylesheet" type="text/css"/>

    <script type="text/javascript">

        function deleteInvestor(id) {
            if (confirm('确实要删除该客户吗?')) {
                $.post("/investorController/delete",
                    {"id": id},
                    function (data) {
                        alert(data.description);
                        window.location.reload();
                    });
            }
        }
    </script>
</head>
<body>
<div id="wrapper">
    <!-- 导航栏部分 -->
    <div th:replace="~{navbar :: nav }"></div>
    <!-- 客户列表查询部分  start-->
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">客户管理</h3>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-body">
                <form method="post" action="/investorController/list" class="form-inline">
                    <div class="form-group">
                        <label for="name">客户名称</label>
                        <!-- 请注意：name属性值与InvestorDto中的属性名保持一致 -->
                        <input id="name" th:value="${name}"
                               name="name" type="text" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <label for="investorLevel">客户等级</label>
                        <!-- 请注意：name属性值与InvestorDto中的属性名保持一致 -->
                        <select id="investorLevel" name="levelID" class="form-control">
                            <option value="">--请选择--</option>
                            <option th:each="level : ${levelList}" th:value="${level.id}"
                                    th:selected="${level.id+'' == levelID}" th:text="${level.description}"></option>
                        </select>
                    </div>

                    <div class="form-group">
                        <label for="investorField">投资领域</label>
                        <!-- 请注意：name属性值与InvestorDto中的属性名保持一致 -->
                        <select id="investorField" name="fieldID" class="form-control">
                            <option value="">--请选择--</option>
                            <option th:each="field : ${fieldList}" th:value="${field.id}"
                                    th:selected="${field.id+'' == fieldID}"
                                    th:text="${field.description}"></option>
                        </select>
                    </div>

                    <div class="form-group">
                        <label for="investorIntent">投资意向</label>
                        <!-- 请注意：name属性值与InvestorDto中的属性名保持一致 -->
                        <select id="investorIntent" name="intentID" class="form-control">
                            <option value="">--请选择--</option>
                            <option th:each="intent : ${intentList}" th:value="${intent.id}"
                                    th:selected="${intent.id+'' == intentID}"
                                    th:text="${intent.description}"></option>
                        </select>
                    </div>
                    <button type="submit" class="btn btn-warning">Search</button>
                </form>
            </div>
        </div>

        <div>
            <a href="/investorController/toInsert" class="btn btn-primary" style="float:left">新建</a>
            <a href="/investorController/list" class="btn btn-success" style="float:right">刷新</a>
        </div>
        <br><br><br>

        <!-- 客户列表 -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">客户信息列表</div>
                    <table class="table table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>编号</th>
                            <th>客户姓名</th>
                            <th>客户级别</th>
                            <th>投资金额</th>
                            <th>投资领域</th>
                            <th>投资意向</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="investor : ${pageInfo.list}">
                            <td th:text="${investor.id}" style="text-align: center"></td>
                            <td th:text="${investor.name}" style="text-align: center"></td>
                            <td th:text="${investor.level}" style="text-align: center"></td>
                            <td th:text="${investor.amount}" style="text-align: center"></td>
                            <td th:text="${investor.field}" style="text-align: center"></td>
                            <td th:text="${investor.intent}" style="text-align: center"></td>
                            <td style="text-align: center">
                                <a th:href="|/investorController/toUpdate?id=${investor.id}|"
                                   class="btn btn-primary btn-xs">修改</a>
                                <a href="#" th:onclick="|deleteInvestor(${investor.id})|"
                                   class="btn btn-danger btn-xs">删除</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <br/>
                    <div class="row">
                        <div class="col-md-6">
                            第[[${pageInfo.pageNum}]]页，共[[${pageInfo.pages}]]页，共[[${pageInfo.total}]]条记录
                        </div>
                        <div class="col-md-6 offset-md-4">
                            <nav aria-label="Page navigation example">
                                <ul class="pagination pagination-sm">
                                    <li class="page-item">
                                        <a class="page-link"
                                           th:href="|/investorController/list?page=1&name=${name}&levelID=${levelID}&fieldID=${fieldID}&intentID=${intentID}|">首页</a>
                                    </li>
                                    <li class="page-item" th:if="${pageInfo.hasPreviousPage}">
                                        <a class="page-link"
                                           th:href="|/investorController/list?page=${pageInfo.pageNum-1}&name=${name}&levelID=${levelID}&fieldID=${fieldID}&intentID=${intentID}|">上一页</a>
                                    </li>
                                    </li>

                                    <li class="page-item" th:each="page : ${pageInfo.navigatepageNums}">
                                        <a class="page-link"
                                           th:href="|/investorController/list?page=${page}&name=${name}&levelID=${levelID}&fieldID=${fieldID}&intentID=${intentID}|"
                                           th:classappend="${page==pageInfo.pageNum ? 'active' : '' }"
                                           th:text="${page}"></a>
                                    </li>


                                    <li class="page-item" th:if="${pageInfo.hasNextPage}">
                                        <a class="page-link"
                                           th:href="|/investorController/list?page=${pageInfo.pageNum+1}&name=${name}&levelID=${levelID}&fieldID=${fieldID}&intentID=${intentID}|">下一页</a>
                                    </li>
                                    <li class="page-item">
                                        <a class="page-link"
                                           th:href="|/investorController/list?page=${pageInfo.pages}&name=${name}&levelID=${levelID}&fieldID=${fieldID}&intentID=${intentID}|">末页</a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 客户列表查询部分  end-->
</div>


</body>
</html>